package com.wixct.controller;
import com.wixct.repository.domain.TBlogTags;
import com.wixct.repository.service.TBlogTagsService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import org.springframework.http.ResponseEntity;
import org.springframework.http.HttpStatus;

/**
* (t_blog_tags)表控制层
*
* @author xxxxx
*/
@RestController
@RequestMapping("/tblogtags")
public class TBlogTagsController {
/**
* 服务对象
*/
@Resource
private TBlogTagsService tBlogTagsService;

/**
* 通过主键查询单条数据
*
* @param id 主键
* @return 单条数据
*/
@GetMapping("{id}")
public ResponseEntity<TBlogTags> queryById(@PathVariable("id") Integer id) {
    return ResponseEntity.ok(this.tBlogTagsService.getById(id));
}

/**
* 新增数据
*
* @param tBlogTags 实体
* @return 新增结果
*/
@PostMapping(value = "/add")
public ResponseEntity< Object> add(TBlogTags tBlogTags) {
    this.tBlogTagsService.save(tBlogTags);
    return new ResponseEntity<>("created successfully", HttpStatus.OK);
}

/**
* 编辑数据
*
* @param tBlogTags 实体
* @return 编辑结果
*/
@PutMapping(value = "/update")
public ResponseEntity< Object> edit(TBlogTags tBlogTags) {
    this.tBlogTagsService.updateById(tBlogTags);
    return new ResponseEntity<>("updated successfully", HttpStatus.OK);
}

/**
* 删除数据
*
* @param id 主键
* @return 删除是否成功
*/
@PostMapping(value = "/delete/{id}")
public ResponseEntity< Object> deleteById(@PathVariable("id") Integer id) {
    this.tBlogTagsService.removeById(id);
    return new ResponseEntity<>("deleted successfully", HttpStatus.OK);
}
}
